﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows;

namespace myWindowsMediaPlayer.ViewModel
{ 
    class masterReadChoiceViewModel : viewModelBase
    {
        private ObservableCollection<libraryViewModel> medias;
        private ICollectionView collectionView;
        private int nb;
        private Uri mediaUri;


        public masterReadChoiceViewModel()
        {
            this.medias = new ObservableCollection<libraryViewModel>();
            this.collectionView = CollectionViewSource.GetDefaultView(this.medias);
            nb = 0;
        }

        public Uri MediaUri
        {
            get
            {
                return mediaUri;
            }
            set
            {
                if (value == null || value != mediaUri)
                {
                    mediaUri = value;
                    OnPropertyChanged("MediaUri");
                }
            }
        }

        public void doubleClick(object sender, RoutedEventArgs e)
        {
            MediaUri = new Uri((collectionView.CurrentItem as libraryViewModel).Path);
        }

        public ObservableCollection<libraryViewModel> Medias
        {
            get { return medias;}
        }

        public int Nb
        {
            get { return nb; }
            set { nb = value; }
        }
    }
}
